//
//  UIBarButtonItem+JM.m
//  OpenSesame
//
//  Created by zhangjiaming on 15/12/24.
//  Copyright © 2015年 OpenSesame. All rights reserved.
//

#import "UIBarButtonItem+JM.h"

@implementation UIBarButtonItem (JM)
+ (UIBarButtonItem *)itemWithTarget:(id)target action:(SEL)action image:(NSString *)image highImage:(NSString *)highImage
{
    UIButton *barButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [barButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [barButton setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [barButton setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateSelected];
    barButton.size = barButton.currentBackgroundImage.size;
    return [[UIBarButtonItem alloc] initWithCustomView:barButton];
}
@end
